home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / HackAddict™ Magazine / HA 1-12 / HackAddict11.sit / HackAddict 11 ƒ / HackAddict™ 11.rsrc / TEXT_136.txt < prev    next >
Text File  |  1998-03-01  |  23KB  |  190 lines

  1.  
  2.         The Ultimate Mac Cracking 
  3.             Guide
  4.  
  5.  
  6. --==< Foreword >==--
  7.  
  8. I would like to apologize to all members of the Hackintosh community for not being able to complete the second part of The Ultimate Macintosh Cracking Guide in time to be published in HackAddict 9! I‚Äôve had some problems including a cancellation of my Internet account. But now I‚Äôm back and here to stay! The second part might be a bit blurry at times as I had to throw together four thousand words in two days! But if you have any questions, feel free to e-mail me. My e-mail address is: prozaq@usa.net
  9.  
  10.  
  11. --==< Table of Contents >==--
  12.  
  13. I. Intro
  14. II. Super ResEdit
  15. III. Using Super ResEdit
  16. IV. Other Uses of Super ResEdit
  17. V. Variations to The Same Theme 
  18. VI. Pay Attention!
  19. VII. Another Cracking Example
  20. VIII. End of Part 2
  21.  
  22.  
  23. --==< Intro >==--
  24.  
  25. Let me start off by refreshing your memory as to what happened in Part 1 of ‚ÄúThe Ultimate Mac Cracking Guide‚Äù. I guided you through how to use MacsBug to find the conditional branch that decides whether the reg. number you entered is valid or not. At this point a couple of things can happen. The first situation is the best for the cracker! The program you‚Äôre trying to crack is glad that you registered your software, updates the preference file, and bothers you about registering no more! In this case you won‚Äôt need ResEdit or any other materials! Be glad that you‚Äôre quest to crack the software was successful!
  26.  
  27. But life ain‚Äôt that sweet! If the above situation occurs you are really lucky, as most softwares are a hell of a lot harder to crack! If the registration box still appears after relaunching the application then it‚Äôs probable that the following situation occurs. The program checks the registration number every time you launch the application, or several times while the application runs. This is when we have to change the source code using ResEdit (The only difference between ResEdit an Super ResEdit is that the later one contains an assembly code editor that allows you to view the contents of the CODE resource as assembly commands, not only as hexadecimal machine codes. Whenever I use the word ‚ÄúResEdit‚Äù I am in fact referring to Super ResEdit!)
  28.  
  29.  
  30. --==< Super ResEdit >==--
  31.  
  32. OK, launch ResEdit and let me explain a bit!  The Mac OS divides a file into two parts. It‚Äôs first part is the ‚ÄúData fork‚Äù, where it keeps data, such as the ASCII characters in a text file. The second part is the ‚ÄúResource fork‚Äù, this is where the action is!  The resource fork contains information of the application such as how the application‚Äôs dialogs look like, how it‚Äôs custom windows look like, how the icons appear in the Finder, what ASCII strings the application will put in error dialogs and a lot more!  In order to keep the Mac as user friendly for the software developer as possible, Apple provides a very humane way to create and edit resources through ResEdit. I will not go through what all the different resource types are used for, as that would take a hell of a long time! But here are the resource types of interest to us:
  33.  
  34. CODE - This is where the program‚Äôs codes is stored in assembly format. These are the commands the program executes once it is launched from the Finder.
  35.  
  36. CDEF - Same use as CODE. It is used in control panels.
  37.  
  38. cdev - Same use as CDEF.
  39.  
  40. INIT - Same use as CODE. It is used in system extensions.
  41.  
  42. DITL - This is where the design of a dialog box can be found. Where the buttons and text fields are designed and can be edited.
  43.  
  44. DLOG - Where the position of a dialog can be changed.
  45.  
  46. ALRT - Where the position of alert boxes can be changed.
  47.  
  48. WIND - Where custom windows can be designed.
  49.  
  50. I can recommend that you play around with ResEdit for a while and get a feel for how it works! HOWEVER! ALWAYS work on a COPY of the application you want to change! Since ResEdit is directly messing around with the structure of the program, if you mess up anything you can definitely screw up the application (and if you‚Äôre lucky your system).
  51.  
  52. For now I will focus on the ‚ÄúCODE‚Äù resource (and all other resources that serve the same purpose). Whenever anyone writes an application, in whatever language, their compiler converts the code into assembly. In assembly every command has it‚Äôs machine language equivalent, which is stored as hexadecimal information. So the CODE resource contains these hexadecimal assembly instructions. When you open up an ID from within CODE resource, then a large window should appear with a bunch of assembly commands and other nice info in it. (If ONLY a small window appears with a bunch of hex numbers in it then you don‚Äôt have Super ResEdit!) If both the big and small windows appeared then that‚Äôs good since you‚Äôll need both. If only the big window appears select ‚ÄúAlways Open‚Äù from the Hex Editor menu. This should bring up the small window with hex numbers in it. The small window represents only the hexadecimal values of the assembly commands while the big window translates these commands into a more perceptive human language (if you can call assembly human).
  53.  
  54. Now if you have the big window up you‚Äôll see 6 columns of information, each of them representing one of the following things (from left to right):
  55. Offset, Address, Opcode, Operand, Comment, Hex.
  56.  
  57. The Offset column represents the of the command with respect to the first command in the subroutine. 
  58. The Address column represents the commands position from the first command in that resource. 
  59. The Opcode section contains all the commands, and the Operand column contains which registers are affected by the command. 
  60. The Comment column helps you see what type of info is moved around.
  61. And the Hex column shows what the opcode and the operand section turns into when it‚Äôs translated to machine language.
  62. The beginning of the different subroutines are represented by a name in red, bold print on the left side of the window. Usually these are just called ‚ÄúAnon#‚Äù. You can see a list of all the subroutines in the Modules menu.
  63.  
  64.  
  65. --==< Using Super ResEdit >==--
  66.  
  67. So what‚Äôs all this good for? Well... as I said before, most programs contain more security then the program discussed in part one of The Ultimate Mac Cracking Guide. Imagine the following situation:
  68. You crack a program with MacsBug. You know this because the ‚Äúthank you registering‚Äù dialog appears. But the next time you launch the application it asks for the reg. number again. What this CAN mean is that after you crack the program with MacsBug the program stores the information you entered in either a preference file or in a resource.  And every time you launch the program it checks to see if the reg. name and number match. So in theory if you change the conditional responsible for the validity of the reg. number in the application itself, then it doesn‚Äôt matter how many times the program checks, as the reg. number you entered will always turn out to be a valid one!
  69. And this is where we use Super ResEdit. Let‚Äôs say that we have established that the application checks for the reg. number every time it starts up.  It is likely that the application uses the same subroutine to check the reg. number at startup as it used when you entered the reg. number in the reg. dialog.
  70. So to use the example from part one, here‚Äôs what I found out from MacsBug:
  71.  
  72.      +0012C 00D2E788   PEA        -$0308(A6)                              | 486E FCF8
  73.      +00130 00D2E78C   PEA        -$0108(A6)                              | 486E FEF8
  74.      +00134 00D2E790   JSR        xxxxxxxxxxx                               | 4EB9 00D2 CDD8
  75.      +0013A 00D2E796   MOVE.B     (A7)+,D0                                | 101F
  76.      +0013C 00D2E798   BEQ.S      XXXXXXXXX+00142        ; 00D2E79E   | 6704
  77.  
  78. And after following through the code I know that the subroutine in 134 does the conversion of the registration number I entered and at offset 13C the conditional checks whether my reg. number is the same as the valid reg. number. When I was dropped into MacsBug after I initiated the ‚Äúmodaldialog‚Äù atrap the following information was given to me by MacsBug:
  79.  
  80.  
  81.   D_PERSONALIZE
  82.      +0009A 010E7956   _ModalDialog                          ; 0028D906   | A991
  83. This means that the modal dialog trap occurs in the subroutine D_PERSONALIZE. Most often though, you will be given something like this by MacsBug when encountering an atrap:
  84.  
  85. A-Trap break at 00D1A908 'CODE 0002 1B8C'+02E88: A97C
  86.  
  87. Here‚Äôs what the two sets of info mean. The first one means that the person who wrote the software decided that he will make life easy for crackers and called the subroutine dealing with registering the software ‚ÄúD_PERSONALIZE‚Äù. 
  88.  
  89. The second info means the following: The atrap occurred in the resource ‚ÄúCODE‚Äù with resource ID 0002. And this is all we need to know! If you open up the application with Super ResEdit and open up the CODE resource with an ID number of 2 you can go to the offset given to you by MacsBug.
  90. If the situation is like the one in the first example where only the name of the subroutine is given then you have to go through each ID number in the CODE resource and look for a subroutine called ‚ÄúD_PERSONALIZE‚Äù. You can find a list of all the subroutines used within an certain ID in the Modules menu.
  91.  
  92. So let‚Äôs say the following I get the following info in MacsBug once I step through the code after the modaldialog atrap:
  93.  
  94. A-Trap break at 00D1A908 'CODE 0002 1B8C'+02E88: A97C 
  95.       blah blah
  96.       blah blah
  97.      +0012C 00D2E788   PEA        -$0308(A6)                              | 486E FCF8
  98.      +00130 00D2E78C   PEA        -$0108(A6)                              | 486E FEF8
  99.      +00134 00D2E790   JSR        xxxxxxxxxxx                               | 4EB9 00D2 CDD8
  100.      +0013A 00D2E796   MOVE.B     (A7)+,D0                                | 101F
  101.      +0013C 00D2E798   BEQ.S      XXXXXXXXX+00142        ; 00D2E79E   | 6704
  102.  
  103. So, lets say that I wanna change the conditional at offset 13C in the source code of the application so that it will branch every time no matter what!
  104. I open the application with Super ResEdit and open up the CODE resource, I open up the resource with ID 2. Then I have to find the offset at 13C. You have to realize that the large window that disassembles the assembly code is only for viewing. Meaning that you can not change anything there! You have to work with the small window containing the Hex Editor info if you want to find and change things. 
  105. So I make the Hex Editor the window active. This brings up a new menu. The ‚ÄúFind‚Äù menu. This allows me to search for hex strings, for ASCII strings or offsets! And since I wanna search for an offset I activate the search for offset dialog and type in 13C. After I hit the Find button two digits are selected in the Hex Editor window (for this example the two digits selected would be 67). If I now activate the big window, I should be at the offset 13C. Meaning that I should be seeing exactly what was displayed to me by MacsBug. Now I could have a closer look at what was going on if I needed to!
  106.  
  107. So I know that I need to change this assembly instruction:
  108. BEQ.S      XXXXXXXXX+00142
  109. It‚Äôs hex equivalent is 6704.  How do I know?  
  110.  
  111. +0013C 00D2E798   BEQ.S      XXXXXXXXX+00142        ; 00D2E79E   | 6704
  112.  
  113. When MacsBug displays a command it shows me the hex equivalent of the command too! It is always the hex number appearing after the ‚Äú|‚Äù sign. (I underlined it and put it into a bold print above). This hex number can be between 4 and 16 digits long. I know that I have to change the BEQ.S command to a BRA (Branch always) command. So I activate the Hex Editor‚Äôs window and type ‚Äú60‚Äù. 
  114. In machine code all branch routines start with a 6. The BRA command is the number 60, and that‚Äôs why I replaced 67 with 60. I DIDN‚ÄôT change the second half of 6704, as ‚Äú04‚Äù contains the information regarding where the conditional should branch to! If I change ‚Äú04‚Äù, then the program will branch to a bad offset and will most likely cause my computer to crash!
  115.  
  116. Now, if I DIDN‚ÄôT want the conditional to branch, I could simply get rid of the command. However, simply deleting 4 digits is not the way! Just deleting 6704, will most likely cause the program to crash! Instead, I will replace the conditional by a NOP command. NOP stands for no operation. Meaning that the processor will not execute any operations for that command. It will simply jump to the next command in line. 
  117. To change the conditional instruction to never branch, activate the Hex Editor window and highlight the next two digits as well (so all together I will now have four digits selected ‚Äú6704‚Äù). Then I would type ‚Äú4e71‚Äù (as this is the equivalent of NOP in machine language). If I now go back to the big window, I can see that the command has been changed to NOP! Success!
  118.  
  119. Now I would save my work and try and run the application again. If it freezes I have goofed up somewhere. If not, lets test it! At this point, however, I will no longer have to crack the programs registration dialog with MacsBug, as I have changed the code within the application to do what I want it to do! So I could just enter anything I wanted as a reg. name and number. If the program says that I entered the wrong registration number, then I goofed up in cracking the program with MacsBug! I have to start from the beginning and look for another conditional.
  120. If I‚Äôm lucky, then everything goes fine, and when I relaunch the application it will say that it is registered to me.
  121.  
  122.  
  123. ---===< Other Uses of Super ResEdit >===---
  124.  
  125. ResEdit is not only useful if you want to change the assembly code of an application! You can use it to help you through the process of cracking. For example, I almost always start off with opening up the program in ResEdit and look around amongst the dialog resources. I‚Äôm looking for the ‚Äúthanx for registering‚Äù dialog. I write down it‚Äôs ID value and if I see that number being mover around in MacsBug than I know that I‚Äôm on the right track! I also try to find the ‚Äúwrong number‚Äù dialog just to see how it looks like! You may also find hidden pictures and shit like that with ResEdit! ResEdit ROCKS! Handle it with care and it‚Äôll be good to you! Mistreat it and it‚Äôll screw up your computer!
  126.  
  127.  
  128. --==< Variations to The Same Theme >==--
  129.  
  130. Up ‚Äòtill now, the situation was that the program used a subroutine to do calculations with the reg. number you entered and then returned from the subroutine and checked to see whether the reg. number you entered was valid or not. 
  131. Now, there is virtually an infinite amount of ways to protect software, and software developers know this! And if they are smart they will use various tricks to protect their softwares!
  132. Another situation you might find yourself in, while cracking a program, is that there are two conditionals you need to change! This means that within the subroutine that checks the reg. number you entered, the program sets two flags. One of the flags is representing that the reg. number is correct or incorrect, and the second flag tells the program whether to update itself to the registered version or not!  This is again a simple example. The developers of the program might have done something ingenious, so it might be a lot more complex than that!
  133. If, however, this is the situation, then you will have to find the two conditionals and change BOTH of them accordingly! 
  134.  
  135.  
  136. ---===< Pay Attention! >===---
  137.  
  138. Therefore, it is extremely important that you know exactly what the hell is going on in the program! When you step through a code in MacsBug pay attention to what is happening to the address registers! When you see that A0, A1,A2 or A3 contains your reg. name or reg. number then you know that you are getting closer! Also look out for the hex value of the reg. number you entered. For example, if you entered ‚Äú12345‚Äù as a reg. number also look for its hex equivalent ‚Äú3039‚Äù! If you see commands like: cmp.l    130(a6),d0     
  139.  and don‚Äôt know how to access that specific part of the memory, then simply type: ‚Äúdm a6+130‚Äù into MacsBug and it will show you the info that is contained 130 bytes away from a6‚Äôs current position. If you can‚Äôt figure out what a command does, refer to the ‚ÄúList of Assembly Commands‚Äù file (included in HackAddict 8 as Appendix A). And if you still can‚Äôt figure out a command then mail me! And remember!  Nothing is uncrackable! It‚Äôs merely a matter of time! If you sit around for long enough you will figure out what the little bugger does and then you‚Äôll also figure out how to crack it!
  140.  
  141.  
  142. ---===< Another Cracking Example >===---
  143.  
  144. I will now guide you through how I cracked a control panel recently. I will not mention any names as I just want this to be a theoretical example to what protection schemes you may encounter. Also this might give you an idea to what you might be doing wrong! What you might be spending too much time on, and things like that!  
  145.  
  146. Cracking the control panel seemed at first as a piece of cake, as the control panel had a subroutine followed by a conditional. So I changed the conditional, and since nothing happened I thought I cracked it! But then I started to look around in the program with ResEdit, and I noticed that the program created STR# resource with my information in it! And since I didn‚Äôt get a ‚Äúthanx for registering‚Äù dialog, I was a bit skeptic of my success! 
  147.  
  148. So I deleted the STR# resource and started from the beginning again! But again when I changed the conditional the program added the STR# resource to itself! ‚ÄúVery fishy‚Äù I thought! So I started to take a closer look in it with ResEdit! I didn‚Äôt find a ‚Äúthanx for registering‚Äù dialog. So I got curious and found in HackersHelper the registration number for an older version of the control panel. I tried the serial number given in HackersHelper and presto! An error dialog greeted me informing me that I was using a PIRATE registration number! What do you say to that? Never had that happen before! Very ingenious if you ask me! 
  149.  
  150. So I found an older version of the control panel on a shareware CD of mine, and when I used the pirate reg. number on that one it worked! And as it turned out the program didn‚Äôt put up a ‚Äúthanx for registering‚Äù dialog, but simply wrote ‚Äúregistered to ProZaq‚Äù in the upper left corner. Tricky! Very Tricky! 
  151.  
  152. But now at least I knew that I have to follow through that subroutine before the conditional! So I did! And the damnest thing happened! Before long I found myself in the subroutine responsible for comparing the reg. name I entered to the reg. names given by Hackers Helper and HackUser! Now this was a hell of a subroutine! It was gonna compare my reg. name to that of a pirate one about 30 times!  I found this out from looking into one of the address registers! So here‚Äôs a trick to do when you‚Äôre faced with a similar situation. Let‚Äôs say that you‚Äôre stuck in a subroutine like this:
  153.  
  154. Shit_routine: (name of subroutine)
  155.      add.b 1,d0
  156.      blah
  157.      blah
  158.      blah
  159.      blah
  160.      another 100 blahs
  161.      cmpi.b    #1000,d0
  162.      bne     shit_routine
  163.      cmpi.b    d3,100(a6,d0)
  164.      rts
  165.  
  166. What the subroutine does is unimportant! The important thing is that it does the same shit 1000 times! After every ‚Äúblah‚Äù it compares the value of d0 to 1000 and if it doesn‚Äôt equal 1000 it adds 1 to d0, and does the ‚Äúblah‚Äùs again. Now for the computer 10000 instructions won‚Äôt take long! But for me to sit around and press return 10000 times would take a bit too long! So here‚Äôs the solution. Use the break command in MacsBug! Just issue MacsBug the command ‚Äúbr addr‚Äù where ‚Äúaddr‚Äù is the address of the command you want the processor to halt at! For example, in MacsBug the last command I gave you in that example subroutine, might look something like this:
  167.  
  168. +0013C 00D2E798   CMPI.B    D3,100(A6,D0)        
  169.  
  170. So if I wanted to be dropped into MacsBug every time the processor executed that specific instruction I would issue the command ‚Äúbr d2e798‚Äù. Make sure that you don‚Äôt use the offset with the plus sign in front of it! (in this case 13C) (You clear break points with the ‚Äúbrc‚Äù command. For more info on using break points type ‚Äúhelp br‚Äù in MacsBug)
  171.  
  172. And so after I used the break command, I regained control of the computer after the program was done checking for the pirate names! Then I found myself in the subroutine responsible for putting my reg. number under an algorithm. And once it was done doing that, I found out that it checked to see if my reg. number was a valid one, and if it was it set TWO flags! It made both d1 and d7 equal one! (I must say that either this code was written with a horrible compiler, or it wasn‚Äôt optimized at all! I could have written the same damn algorithm in assembly, so that it would have taken about half as many commands to achieve the same thing!)
  173.  
  174. And after that there was a conditional within the subroutine checking to see if the hex value of the reg. number I entered (stored in d0) equaled that of the correct one (stored as an offset to A6). And it was a good thing that I left a br mark at this conditional by an accident because the program rechecked my reg. number four more times before it accepted that I entered the right reg. number! What a bitch!
  175.  
  176. And since I followed through the code thurally I also found out what algorithm it used to derive the correct reg. number! So if I wanted I wouldn‚Äôt have needed to change anything in the program! I could simply calculate what reg. number would be valid for the reg. name ‚ÄúProZaq‚Äù and simply enter that in the registration dialog!
  177.  
  178. I did however also change it‚Äôs code with Super ResEdit. I changed the conditional that the program referred to 4 times! And so the next time I could enter any reg. name and any reg. number and it would accept it!
  179.  
  180. So here‚Äôs a summary of what types of security precautions the software used!
  181.    1. It checked to see if my reg. name was that found in HackersHelper or HackUser. This is a very unusual thing to do! I‚Äôve never seen software of this caliber do this before!
  182.    2. It did a bunch of calculation with my reg. name. Almost all programs with serial number protections do this!
  183.    3. It compared the reg. number I entered to a valid one. Again, this step is used by most softwares!
  184.    4. If these two numbers were equal it set two flags, one in d1 and one in d7. Quite a common technique. Makes life a bit of a bitch!
  185.    5. It rechecked 4 more times whether the reg. number I entered was valid or not. G‚ÄôDamn! Give it a break! Most programs (of this size) only check for the validity of the two numbers once or twice! But since it was the same conditional that did the checking, after I changed it with ResEdit, I could enter any reg. name and number I wanted!
  186.  
  187.  
  188. ---===< End of Part 2 >===---
  189.  
  190. Part two of The Ultimate Mac Cracking Guide might have been a bit sloppy but I didn‚Äôt have much time to put it together! In the next part I will discuss other tricks program writers use to protect their softwares. I will also try and describe how to find a reg. number that will work for a specific reg. name. And if time and space permits I will also give suggestions to what to do when a-traps won‚Äôt work!